/**
  * @Description: WoShop商城
  * @Author: Parker
  * @Copyright: 武汉一一零七科技有限公司©版权所有
  * @Link: www.s1107.com
  * @Contact: QQ:2487937004
  */


<script>
import autoUpdater from "./utils/autoUpdater.min.js";
import {
	        mapState,  
	        mapMutations  
	    } from 'vuex'; 
export default {
 
    onHide: function () {
        console.log("App Hide");
		// this.logout()
    },
    data() {
        return {
            msg: {}
        };
    },
    onLaunch() {
								
          this.im();
		  // plus.screen.lockOrientation("portrait-primary");
         const token = uni.getStorageSync('token');
         if(token){
           this.$store.commit('loginStatus',true)
         }
        /* #ifdef APP-PLUS */
        var info = plus.push.getClientInfo();
        var options = {
            cover: true
        };

        plus.push.setAutoNotification(true);

        plus.push.addEventListener(  
            "click",
            function (msg) {
                uni.navigateTo({
                    url: "/pagesB/message/message"	
                });
                console.log(JSON.stringify(msg));
                console.log(msg.payload.type);
            },
            false
        );
	
        //监听在线消息事件
        plus.push.addEventListener(
            "receive",
            function (msg) {
                console.log("接收事件监听");
                console.log(msg);
                if (msg.payload !== "LocalMSG") {
                    plus.push.createMessage(msg.content, "LocalMSG", options);
                }
            },
            false
        );
        /* #endif */

		

        // uni.setStorageSync('memberParams', url.split('=')[0].replace('#'))
        /* #ifdef APP-PLUS */

        /* #endif */
    },
  methods:{
	   ...mapMutations(['logout','logins']),
	  getLocation(){
		  // 先判断定位权限是否开启
		  // uni.getLocation({
		  //     success(){
		  //     },
		  //     fail(e) {
				//   // confirm(e,"到底是啥")
		  //        // App跳转系统的设置界面
		  //         // #ifdef APP-PLUS
		  //         uni.getSystemInfo({
		  //             success(res) {
		  //                 if(res.platform=='ios'){ //IOS
		  //                     plus.runtime.openURL("app-settings://");
		  //                 } else if (res.platform=='android'){ //安卓
		  //                     let main = plus.android.runtimeMainActivity();
		  //                     let Intent = plus.android.importClass("android.content.Intent");
		  //                     let mIntent = new Intent('android.settings.ACTION_SETTINGS');
		  //                     main.startActivity(mIntent);
		  //                 }
		  //             }
		  //         });
		  //         // #endif
		  //     }
		  // })
		  // uni.getLocation({
		  //     type: 'wgs84',
		  //     success: function (res) {
		  //         console.log('当前位置的经度：' + res.longitude);
		  //         console.log('当前位置的纬度：' + res.latitude);
		  //     }
		  // });
	  },
      upVersion(){
        const baseUrl = uni.getStorageSync('baseUrl')

        const server = `${baseUrl}version/versions`;
        const res = uni.getSystemInfoSync();
        const apptype = res.platform;
        console.log(plus.runtime.version);
        var req = {
          appid: plus.runtime.appid,
          version: plus.runtime.version,
          client: apptype
        };
        uni.request({
          url: server,
          data: req,
          method: "POST",
          success: res => {
            console.log(res);
            if (res.data.status === 1) {
              autoUpdater.init({
                packageUrl: res.data.data.urls,
                content: res.data.data.content,
                contentAlign: "center",
                cancel: "取消升级",
                cancelColor: "#007fff"
              });
              autoUpdater.show();
            }
          },
          fail: err => {
            console.log(222);
          }
        });
      }
  },
  onShow() {
  	this. getLocation()
	// uni.switchTab({
	// 	url: '/pages/tabBar/Home'
	// });
	/**
	 * 获取本地存储中launchFlag的值
	 * 若存在，说明不是首次启动，直接进入首页；
	 * 若不存在，说明是首次启动，进入引导页；
	 */
	
  },
  
  onError(){
      console.log('监听到error')

    // ... Error: 错误处理
  },
  onUnhandledRejection(){
    
    console.log('监听Promise 拒绝事件')
    // ... Promise 错误处理
  },
  onPageNotFound(){
      this.$toast('当前页面不存在')
  }
};
</script>
<style lang="less">

@import "./static/css/index.less";
@import "/static/css/iconfont.css";
@import "graceUI/graceUI.css";
//@import "static/uni.css";
.goodsPrice{
  font-size: 32upx;
  font-weight: bold;
  color: red;
}
.u-font-bold{
  font-weight: 800;
}
.u-flex{
  display: flex;
}
.u-col-center{
  align-items: center;
}
.u-row-center{
  justify-content: center;
}
.u-m-t-20{
  margin-top: 20upx;
}
.u-row-between{
  justify-content: space-between;
}
.u-text-center{
  text-align: center;
}
/deep/ .u-subsection .u-item-text{
  justify-content: center;
}
//@import "/static/css/mixins.scss";
//@import "/static/css/index.scss";
//@import "uview-ui/index.scss";

// @import "video.js/dist/video-js.css";
// @import "vue-video-player/src/custom-theme.css";
/* #ifdef H5 */
// @import "video.js/dist/video-js.css";
// @import "vue-video-player/src/custom-theme.css";
/* #endif */
view,
navigator {
    box-sizing: border-box;
}

page {
    background: #f4f4f4;
}

.navigator-hover {
    background: #eee !important;
}

.span weixin-parse-template {
    margin: 0 !important;
}

.text-hover {
    background: transparent;
    opacity: 0.5;
}

.bg-hover {
    background: #eee !important;
}

.flex {
    display: flex;
}

.flex-align {
    display: flex;
    align-items: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.u-m-l-20{
  margin-left: 20upx;
}
.u-m-10{
  margin: 10upx;
}
.u-p-l-15{
  padding-left: 15upx;
}
.u-m-t-10 {
 margin-top: 10upx;
}
.u-m-b-10{
  margin-bottom: 10upx;
}
.u-line-1{
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
  width:100%;
}
.u-line-2{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.u-flex-wrap{
  flex-wrap: wrap;
}
.u-font-lg{
  font-size:32upx;
}
.u-font-sm{
  font-size: 20upx;
}
.colorWhite{
  color:#fff
}
.flex1 {
    flex: 1;
}
.u-font-xl{
  font-size: 36upx;
}
.rmbSymbol{
  font-size:20upx;
  color:#b1b2b5;
  margin-right: 8upx;
}
.solid {
    border: 1upx solid #eee;
}

.no-more {
    line-height: 88upx;
    text-align: center;
    color: #999;
    font-size: 26upx;
}

.button {
    height: 100upx;
    background: rgba(236, 73, 73, 1);
    border-radius: 50px;
    font-size: 34upx;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    position: relative;
}

.underLine {
    width: 46upx;
    height: 5upx;
    margin: 8upx auto 0;
    position: relative;
    background: transparent;
}

.underLine.active {
    background: rgba(250, 62, 63, 1);
}

.underLine::before {
    width: 6upx;
    height: 5upx;
    background: #fff;
    position: absolute;
    content: "";
    top: 0;
    right: 10upx;
    transform: skewX(45deg);
}

.btn-color {
    background: rgba(236, 73, 73, 1);
    color: #fff;
}

.sendCode {
    padding: 11upx 25upx;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 29upx;
    font-size: 28upx;
}

.extend-click {
    position: relative;
}

.extend-click::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
}

.status {
    height: var(--status-bar-height);
}

.f22 {
    font-size: 22upx;
}

.f24 {
    font-size: 24upx;
}

.f26 {
    font-size: 26upx;
}

.f28 {
    font-size: 28upx;
}

.f30 {
    font-size: 30upx;
}

.f32 {
    font-size: 32upx;
}

.c3 {
    color: #333;
}

.c6 {
    color: #666;
}

.c9 {
    color: #999;
}

.more {
    width: 11upx;
    height: 24upx;
    background: url("/static/images/viewMore2.png");
    background-size: cover;
}


.select.active {
    background: url("/static/images/choosed-red.png");
    background-size: cover;
}

uni-view {
    line-height: 1.4;
}

.pay-btn {
  margin-top: 80upx;
  text-align: center;
  color: #fff;
  padding: 25upx ;
  border-radius: 200px;
  background-image:linear-gradient(to left, #ffa468, #fa3f3f);
}
.u-m-l-10{
  margin-left: 10upx;
}
</style>
